package com.datastructure.test.happynum;

public class HappyNum {

    public static void main(String[] args) {

    }

    public boolean happynum (int n) {
        // write code here
        while(n/10!=0){
            int temp=0;
            while(n!=0){
                temp+=(n%10)*(n%10);
                n/=10;
            }
            n=temp;
        }
        return n==1;
    }
}
